package mo.leetcode_hot;

public class L53 {

    public int maxSubArray(int[] nums) {
        int max = nums[0];
        int cur = 0;
        for (int num : nums) {
            cur = Math.max(cur + num, num);
            max = Math.max(max, cur);
        }
        return max;
    }

    public static void main(String[] args) {
        L53 test = new L53();
        System.out.println(test.maxSubArray(new int[]{5,4,-1,7,8}));
    }

}
